//
//  NearbyFriendsCell.m
//  GolfFriend
//
//  Created by vescky on 13-12-16.
//  Copyright (c) 2013年 vescky.org. All rights reserved.
//

#import "NearbyFriendsCell.h"
#import "UIImageView+MJWebCache.h"
#import "CommonUtility.h"
#import "AppsLocationManager.h"
#import <QuartzCore/QuartzCore.h>

@interface NearbyFriendsCell () {
    NSMutableDictionary *userInfoDict;
}

@end

@implementation NearbyFriendsCell


- (void)setDataInfo:(NSDictionary*)dict {
    userInfoDict = [[NSMutableDictionary alloc] initWithDictionary:dict];
    NSString *avatarLink = [userInfoDict objectForKey:@"avatar"] ? [userInfoDict objectForKey:@"avatar"] : @"";
    NSString *userName = [userInfoDict objectForKey:@"nickName"];
    NSString *mottoString = [userInfoDict objectForKey:@"motto"];
    if (!userName || userName.length < 1) {
        userName = @"匿名";
    }
    labelUserName.text = userName;
    
    if (mottoString && mottoString.length > 0) {
       labelMotto.text = mottoString;
        labelMotto.layer.cornerRadius = 3.0;
    }
    else {
        labelMotto.hidden = YES;
    }
    
//    CLLocation *l2 = getGfLocation([NSString stringWithFormat:@"%@,%@",[userInfoDict objectForKey:@"lastLoginLongitude"],[userInfoDict objectForKey:@"lastLoginLatitude"]]);
//    double dist = [[AppsLocationManager sharedManager] getDistance:l2];
    labelDistance.text = getFormatedDistance([[dict objectForKey:@"distance"] doubleValue] * 1000);
    
    [imgvAvatar setImageURLStr:avatarLink placeholder:Default_Avatar];
    imgvAvatar.layer.cornerRadius = imgvAvatar.frame.size.width / 2.0;
}


@end
